home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs_src_gs.lha / gs5.03 / gscrypt1.h < prev    next >
Text File  |  1997-03-23  |  2KB  |  46 lines

  1. /* Copyright (C) 1990, 1992, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gscrypt1.h */
  20. /* Interface to Adobe Type 1 encryption/decryption. */
  21.  
  22. /* Normal public interface */
  23. typedef ushort crypt_state;
  24. int gs_type1_encrypt(P4(byte *dest, const byte *src, uint len,
  25.             crypt_state *pstate));
  26. int gs_type1_decrypt(P4(byte *dest, const byte *src, uint len,
  27.             crypt_state *pstate));
  28.  
  29. /* Define the encryption parameters and procedures. */
  30. #define crypt_c1 ((ushort)52845)
  31. #define crypt_c2 ((ushort)22719)
  32. /* c1 * c1' == 1 mod 2^16. */
  33. #define crypt_c1_inverse ((ushort)27493)
  34. #define encrypt_next(ch, state, chvar)\
  35.   (chvar = ((ch) ^ (state >> 8)),\
  36.    state = (chvar + state) * crypt_c1 + crypt_c2)
  37. #define decrypt_this(ch, state)\
  38.   ((ch) ^ (state >> 8))
  39. #define decrypt_next(ch, state, chvar)\
  40.   (chvar = decrypt_this(ch, state),\
  41.    decrypt_skip_next(ch, state))
  42. #define decrypt_skip_next(ch, state)\
  43.   (state = ((ch) + state) * crypt_c1 + crypt_c2)
  44. #define decrypt_skip_previous(ch, state)\
  45.   (state = (state - crypt_c2) * crypt_c1_inverse - (ch))
  46.